package solved;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/*
 ID:	liluyan1
 LANG:	JAVA
 TASK:	beads
 */
public class beads {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("beads.in"));
		f.readLine();
		int count = new beads().maxCut(f.readLine().trim());
		
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"beads.out")));
		out.println(count);
		out.close();
		System.exit(0);
	}
	
	// Solution 1: count all flip points
	
	private int maxCut(String beads) {
		int max = cut(0, beads);
		char state = beads.charAt(0);
		for (int i=1; i<beads.length(); i++) {
			char c = beads.charAt(i);
			if (c == 'w' || c == state) continue;
			if (state == 'w') {
				state = c; continue;
			}
			max = Math.max(max, cut(i, beads));
			state = c;
		}
		return max;
	}
	
	private int cut(int pos, String beads) {
		int N = beads.length();
		char cur = beads.charAt(pos);
		int i = (pos + 1) % N;
		while (i!=pos && (beads.charAt(i)==cur || beads.charAt(i)=='w' || cur=='w')) {
			if (cur == 'w') cur = beads.charAt(i);
			i = (i + 1) % N;
		}
		if (i == pos) return N;
		int len1 = (i - pos + N) % N;
		
		int pos2 = (pos - 1 + N) % N;
		cur = beads.charAt(pos2);
		int j = (pos2 - 1 + N) %N;
		while (j!=i-1 && (beads.charAt(j)==cur || beads.charAt(j)=='w') || cur=='w') {
			if (cur == 'w') cur = beads.charAt(j);
			j = (j - 1 + N) % N;
		}
		int len2 = (pos2 - j + N) % N;
		
		return len1 + len2;
	}
	
	// Solution 2: DP
	private int maxCut2(String beads) {
		int N = beads.length();
		int[] left = new int[N];
		int[] right = new int[N];
		
		
		
		return 0;
	}
}
